bitkeeper revision 1.1159.272.9 (424131e1AxW6hgsgUY2M3meFO0k4MQ)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 23 Mar 2005 09:07:45 +0000 (09:07 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 23 Mar 2005 09:07:45 +0000 (09:07 +0000)
libxc reacts to memory allocation delay because memory is on the
scrub list.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/xc_private.h
xen/common/domain.c

index c05ae491d9951950eefbd062e01b9873a3012f87..a48156000adb71a8044de9e2774b952331a39719 100644 (file)
@@ -72,7 +72,7 @@ static inline int do_xen_hypercall(int xc_handle,
 
 static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
 {
-    int ret = -1;
+    int ret = -1, retries = 0;
     privcmd_hypercall_t hypercall;
 
     op->interface_version = DOM0_INTERFACE_VERSION;
@@ -86,8 +86,18 @@ static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
         goto out1;
     }
 
+ again:
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
     {
+        if ( (errno == EAGAIN) && (retries++ < 10) )
+        {
+            /*
+             * This was added for memory allocation, where we can get EAGAIN
+             * if memory is unavailable because it is on the scrub list.
+             */
+            sleep(1);
+            goto again;
+        }
         if ( errno == EACCES )
             fprintf(stderr, "Dom0 operation failed -- need to"
                     " rebuild the user-space tool set?\n");
index fa07f2baf9f4ac42df7080e837ad28aa69468af5..30b0677fbb06156e87de44afccf7df55e712839e 100644 (file)
@@ -197,7 +197,7 @@ unsigned int alloc_new_dom_mem(struct domain *d, unsigned int kbytes)
         if ( unlikely((page = alloc_domheap_page(d)) == NULL) )
         {
             domain_relinquish_memory(d);
-            return -ENOMEM;
+            return list_empty(&page_scrub_list) ? -ENOMEM : -EAGAIN;
         }
 
         /* Initialise the machine-to-phys mapping for this page. */